<%--
  Created by IntelliJ IDEA.
  User: USER
  Date: 2021.07.13
  Time: 22:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
</head>
<body>
<button id="btn">postajax</button>
<button id="getbtn">getajax</button>
<script src="/layui/layui.js"></script>
<script>
    // $.get('/url',function (gfudkjgdsf) {
    //
    // });
    // $.post('/url',{'id':1,'name':'张三'},function (data){
    //
    // });
    //
    // $.ajax(
    //     url:'/url'
    // });
    layui.define(function () {
        const $=layui.$;
        const layer=layui.layer;

        $('#getbtn').click(function (){
            $.get('/doajax.sai?id=22&name=李四',function (ddd) {
                layer.msg(ddd.id+' '+ ddd.name);
            });
        });




        $('#btn').click(function () {
            $.ajax({
                url:'/doajax.sai',
                method:'post',
                data:{'id':1,'name':'张三'},
                success:function (data) {
                    //do everything
                    layer.msg(data);
                },
                error:function () {
                    layer.msg('访问失败！');
                }
            });
        });

    });
</script>

</body>
</html>
